<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>体验店活动信息管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			//$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					var startTimeInput = $("input[name=startTime]").val();
					var endTimeInput = $("input[name=endTime]").val();
					var startTime = new Date(startTimeInput.replace(/\-/g, "\/")).getTime();
					var endTime = new Date(endTimeInput.replace(/\-/g, "\/")).getTime();
					var currentTime = new Date().getTime();
					if (currentTime > endTime) {
						top.$.jBox.tip('结束时间不能小于等于当前时间','warning');
						return;
					}
					else if (endTime <= startTime) {
						top.$.jBox.tip('结束时间不能小于等于开始时间','warning');
						return;
					}
					else {
						loading('正在提交，请稍等...');
						form.submit();
					}
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/kpoint/activity/kPointActivity/">体验店活动信息列表</a></li>
		<li class="active"><a href="${ctx}/kpoint/activity/kPointActivity/form?id=${kPointActivity.id}">体验店活动信息<shiro:hasPermission name="kpoint:activity:kPointActivity:edit">${not empty kPointActivity.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="kpoint:activity:kPointActivity:edit">查看</shiro:lacksPermission></a></li>
	</ul><br/>
	<form:form enctype="multipart/form-data" id="inputForm" modelAttribute="kPointActivity" action="${ctx}/kpoint/activity/kPointActivity/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<sys:message content="${message}"/>		
		<div class="control-group">
			<label class="control-label">体验店名称：</label>
			<div class="controls">
				<sys:treeselect id="kPointMain" name="kPointMain.id" value="${kPointActivity.kPointMain.id}" labelName="kPointMain.name" labelValue="${kPointActivity.kPointMain.name}"
					title="体验店" url="/kpoint/kPointMain/treeData" extId="${kPointMain.id}" cssClass="" allowClear="true"/>
				<span class="help-inline"><!-- <font color="red">*</font> --> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">地理位置：</label>
			<div class="controls">
				<sys:treeselect id="activityArea" name="activityArea.id" value="${kPointActivity.activityArea.id}" labelName="activityArea.name" labelValue="${kPointActivity.activityArea.name}"
					title="区域" url="/sys/area/treeData" cssClass="" allowClear="true" notAllowSelectParent="true"/>
				<span class="help-inline"><!-- <font color="red">*</font> --> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">活动标题：</label>
			<div class="controls">
				<form:input path="title" htmlEscape="false" maxlength="100" class="input-xlarge required"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">详细地址：</label>
			<div class="controls">
				<form:input path="fullAddress" htmlEscape="false" maxlength="255" class="input-xlarge required"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<%-- <div class="control-group">
			<label class="control-label">状态：</label>
			<div class="controls">
				<form:select path="status" class="input-xlarge ">
					<form:option value="" label=""/>
					<form:options items="${fns:getDictList('k_point_status')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
			</div>
		</div> --%>
		<div class="control-group">
			<label class="control-label">开始时间：</label>
			<div class="controls">
				<input name="startTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate required"
					value="<fmt:formatDate value="${kPointActivity.startTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">结束时间：</label>
			<div class="controls">
				<input name="endTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate required"
					value="<fmt:formatDate value="${kPointActivity.endTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">类型：</label>
			<div class="controls">
				<form:select path="type" class="input-xlarge required" onchange="kPointChangeType();">
					<form:option value="" label=""/>
					<form:options items="${fns:getDictList('k_point_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
				<span class="help-inline"><font color="red">*</font> </span>
				<script type="text/javascript">
					function kPointChangeType(){
						var value = $("#inputForm select[name=type]").val();
						if (value == 1) {
							$("#k_point_activity_linkurl").show();
						} else {
							$("#k_point_activity_linkurl").hide();
						}
					}
					$(function(){kPointChangeType();});
				</script>
			</div>
		</div>
		<div class="control-group" id="k_point_activity_linkurl">
			<label class="control-label">链接地址：</label>
			<div class="controls">
				<form:input path="linkUrl" htmlEscape="false" maxlength="255" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">封面图：</label>
			<div class="controls">
				<%-- <input type="hidden" id="imageUrl" name="imageUrl" value="${pageContext.request.contextPath}${kPointActivity.imageUrl}" />
				<sys:ckfinder input="imageUrl" type="thumb" uploadPath="/kpoint/kPointActivity" selectMultiple="false"/> --%>
				<c:if test="${kPointActivity.imageUrl ne null && kPointActivity.imageUrl ne '' }">
					<img src="${fns:getConfig('fastdfs_file_url')}${kPointActivity.imageUrl}" style="width:auto;height:80px;"/><br><br>
				</c:if>
				<input type="hidden" name="imageUrl" value="${kPointActivity.imageUrl}" />
				<input id="activityFileName" type="text" readonly="readonly" style="width:360px;margin-bottom:0px;"/>
		   		<input accept="image/*" name="activityFile" id="activityFile" type="file" style="display:none" />
		      	<input id="activityFileSelect" class="btn btn-primary" type="button" value="选择图片" onclick="$('#activityFile').click();" />
				<script type="text/javascript">
					$('#activityFile').change(function() {
						var fileValue = document.getElementById("activityFile").files; 
						$('#activityFileName').val(fileValue[0].name);  
					});
				</script>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">描述：</label>
			<div class="controls">
				<form:textarea path="remarks" htmlEscape="false" rows="4" maxlength="1000" class="input-xxlarge "/>
			</div>
		</div>
		<div class="form-actions">
			<shiro:hasPermission name="kpoint:activity:kPointActivity:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>